load(
    "//tools:defaults.bzl",
    "markdown_to_html",
    "ng_project",
    "ng_web_test_suite",
    "sass_binary",
    "ts_project",
)
load("//tools/adev-api-extraction:extract_api_to_json.bzl", "extract_api_to_json")

package(default_visibility = ["//visibility:public"])

ng_project(
    name = "drag-drop",
    srcs = glob(
        ["**/*.ts"],
        exclude = ["**/*.spec.ts"],
    ),
    assets = [
        ":resets_scss",
    ],
    deps = [
        "//:node_modules/@angular/common",
        "//:node_modules/@angular/core",
        "//:node_modules/rxjs",
        "//src:dev_mode_types",
        "//src/cdk/a11y",
        "//src/cdk/bidi",
        "//src/cdk/coercion",
        "//src/cdk/platform",
        "//src/cdk/private",
        "//src/cdk/scrolling",
    ],
)

# TODO(crisbeto): this should be `ng_project`, but will require some refactors of the shared tests.
ts_project(
    name = "unit_test_sources",
    testonly = True,
    srcs = glob(
        ["**/*.spec.ts"],
        exclude = ["**/*.e2e.spec.ts"],
    ),
    deps = [
        ":drag-drop",
        "//:node_modules/@angular/common",
        "//:node_modules/@angular/core",
        "//:node_modules/rxjs",
        "//src/cdk/bidi",
        "//src/cdk/platform",
        "//src/cdk/scrolling",
        "//src/cdk/testing/private",
    ],
)

sass_binary(
    name = "resets_scss",
    src = "resets.scss",
)

ng_web_test_suite(
    name = "unit_tests",
    deps = [":unit_test_sources"],
)

markdown_to_html(
    name = "overview",
    srcs = [":drag-drop.md"],
)

filegroup(
    name = "source-files",
    srcs = glob(
        ["**/*.ts"],
        exclude = ["**/*.spec.ts"],
    ),
)

extract_api_to_json(
    name = "json_api",
    srcs = [
        ":source-files",
    ],
    entry_point = ":index.ts",
    module_name = "@angular/cdk/drag-drop",
    output_name = "cdk_drag_drop.json",
    private_modules = [""],
    repo = "angular/components",
)
